import Taro, { Component } from '@tarojs/taro'
import { View } from '@tarojs/components'
import http from '@/api'

export default class TestPay extends Component {
    componentDidMount() {
        this.lcgNotify()
    }

    // 单笔交易查询
    async lcgNotify() {
        const { mercOrdNo } = this.$router.params

        if (mercOrdNo) {
            Taro.showLoading({ title: '支付中' })
                const response = await http.lcgNotify({ mercOrdNo })
                if (response.traSts == 0) {
                    // 支付成功
                    Taro.hideLoading()
                    Taro.showToast({
                        title: '支付成功',
                        icon: 'success',
                        duration: 1000
                    }).then(() => {
                        if (response.LISTS[0].tradeNm == '车辆运输') {
                            Taro.navigateTo({
                                url: '/pages/consignment/consignment'
                            })
                        } else if (response.LISTS[0].tradeNm == '车辆购买') {
                            Taro.navigateTo({
                                url: `/pages/shoporders/shoporders?active=1`
                            })
                        }
                    })
                } else {
                    this.lcgNotify()
                }
        }
    }

    render() {
        return (
            <View></View>
        )
    }
}
